package com.enzoism.testspring.transaction.tx;

import java.util.concurrent.atomic.AtomicLong;

public class TransactionInfo {
    private final AtomicLong atomicLong = new AtomicLong();
    //1 成功  0 失败
    private volatile int status = 0;

    public void setSuccessStatus(StatusType type) {
        if (type.getCode() != status) {
            atomicLong.compareAndSet(0, type.getCode());
        }
    }

    public void setFailStatus(StatusType type) {
        if (type.getCode() != status) {
            atomicLong.compareAndSet(1, type.getCode());
        }
    }
}
